package com.huawei.appmarket.service.store.awk.card;

import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.GradientDrawable;
import android.graphics.drawable.GradientDrawable.Orientation;
import android.text.TextUtils;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;
import com.huawei.appgallery.foundation.ui.framework.cardkit.bean.CardBean;
import com.huawei.appgallery.foundation.ui.framework.widget.button.DownloadButton;
import com.huawei.appmarket.service.store.awk.bean.SubstanceListCardBean;
import o.azb;
import o.cgz;
import o.ckd;
import o.dke;
import o.Logger;
import o.dof;
import o.ContentManager;
import o.eho;
import o.eqx;
import o.eqz;
import o.erq;
import o.evf;
import o.ewm.c;
import o.ewm.d;
import o.ewm.j;
import o.fmw;

public class SubstanceListCardDlItem extends AbstractSubstanceListItemCard implements eqz {
    private View ʻ;
    private TextView ʼ;
    private ImageView ʽ;
    private ImageView ˋ;
    private String ˋॱ;
    private TextView ˏॱ;
    private TextView ͺ;
    private View ॱॱ;
    private TextView ᐝ;

    static class e {
        private e() {
        }

        public void ˎ(ImageView imageView) {
            if (evf.ˊ(imageView)) {
                imageView.setImageDrawable((Drawable) fmw.ˏ(imageView.getContext(), o.ewm.e.ꜞ, "drawable"));
            } else {
                imageView.setImageResource(o.ewm.e.ꜞ);
            }
        }

        public void ˊ(DownloadButton downloadButton) {
            if (evf.ˊ(downloadButton)) {
                new eho(c.ˊˊ, o.ewm.e.ﾞ, c.ᐝॱ).ॱ(downloadButton);
                return;
            }
            downloadButton.setButtonStyle(new dke(downloadButton.getContext(), -16777216, -16777216, o.ewm.e.ˋˊ, false, 0));
            downloadButton.setIsImmersion(true);
            downloadButton.ॱ();
        }
    }

    public SubstanceListCardDlItem(Context context) {
        super(context);
    }

    public cgz ˏ(View view) {
        ˋ((DownloadButton) view.findViewById(j.ᐨᐝ));
        this.ˋ = (ImageView) view.findViewById(j.ᑊ);
        this.ᐝ = (TextView) view.findViewById(j.ᵔॱ);
        this.ʼ = (TextView) view.findViewById(j.ᐨˊ);
        this.ʽ = (ImageView) view.findViewById(j.ᴵॱ);
        this.ʻ = view.findViewById(j.ॱˌ);
        this.ॱॱ = view.findViewById(j.ॱㆍ);
        this.ͺ = (TextView) view.findViewById(j.ᐨˋ);
        this.ˏॱ = (TextView) view.findViewById(j.ㆍʼ);
        return this;
    }

    public void ˏ(CardBean cardBean) {
        super.ˏ(cardBean);
        SubstanceListCardBean substanceListCardBean = (SubstanceListCardBean) cardBean;
        if (Logger.ˎ()) {
            Logger.ˏ("SubstanceListCardDlItem", "cardInfoBean.getIcon_()=" + substanceListCardBean.ॱˌ());
        }
        String str = (String) this.ʽ.getTag();
        if (dof.ˋ(str) || !str.equals(substanceListCardBean.ॱˌ())) {
            if (Logger.ˎ()) {
                Logger.ˏ("SubstanceListCardDlItem", "cardInfoBean.getBannerUrl_()=" + substanceListCardBean.ʻᐝ());
            }
            str = (String) this.ˋ.getTag();
            if (dof.ˋ(str) || !str.equals(substanceListCardBean.ʻᐝ())) {
                boolean z = substanceListCardBean.ᐧॱ() == 1;
                if (TextUtils.isEmpty(substanceListCardBean.ॱˌ()) || z) {
                    this.ʽ.setVisibility(8);
                    if (TextUtils.isEmpty(substanceListCardBean.ʽˋ())) {
                        this.ͺ.setVisibility(8);
                    } else {
                        this.ͺ.setText(substanceListCardBean.ʽˋ());
                        this.ͺ.setVisibility(0);
                    }
                } else {
                    this.ͺ.setVisibility(8);
                    this.ʽ.setVisibility(0);
                    this.ʽ.setImageResource(o.ewm.e.ꓸ);
                }
                if (!TextUtils.isEmpty(substanceListCardBean.ॱˌ())) {
                    eqx.ˏ(this.ʽ, substanceListCardBean.ॱˌ(), "app_default_icon");
                }
                new e().ˎ(this.ˋ);
                this.ʻ.setBackgroundColor(0);
                this.ॱॱ.setBackgroundColor(0);
                this.ᐝ.setTextColor(-16777216);
                new e().ˊ(ʽ());
                if (substanceListCardBean.ٴ() != 0) {
                    this.ʼ.setText(substanceListCardBean.ߴ());
                } else {
                    this.ʼ.setText(substanceListCardBean.ʽˊ());
                }
                this.ʼ.setTextColor(-16777216);
                this.ᐝ.setText(substanceListCardBean.ʾॱ());
                this.ˋॱ = substanceListCardBean.ʿॱ();
                Context ˋ = ContentManager.getInstant().getContext();
                eqx.ˏ(ˋ.getResources().getDimensionPixelSize(d.ᐝᐝ), ˋ.getResources().getDimensionPixelSize(d.ॱʻ), this.ˋ, substanceListCardBean.ʻᐝ(), "image_default_icon", this, true);
                this.ʽ.setTag(substanceListCardBean.ॱˌ());
                this.ˋ.setTag(substanceListCardBean.ʻᐝ());
                ˋ(this.ˏॱ, substanceListCardBean.ˋʻ());
                ᐝ(this.ʼ);
                return;
            }
            Logger.ˎ("SubstanceListCardDlItem", "not need to refresh");
            return;
        }
        Logger.ˎ("SubstanceListCardDlItem", "not need to refresh");
    }

    public void ॱ(Bitmap bitmap) {
        int i = -1;
        if (bitmap != null) {
            try {
                int ॱ = erq.ॱ(this.ˋॱ, bitmap);
                int ˊ = erq.ˊ(ॱ, 0.8f);
                this.ʻ.setBackground(new GradientDrawable(Orientation.BOTTOM_TOP, new int[]{ॱ, ˊ}));
                this.ॱॱ.setBackground(new GradientDrawable(Orientation.BOTTOM_TOP, new int[]{ˊ, 0}));
                boolean ˏ = erq.ˏ(ॱ);
                this.ʼ.setAlpha(azb.ˋ(this.ʼॱ, d.ߺ));
                if (ˏ) {
                    this.ʼ.setAlpha(azb.ˋ(this.ʼॱ, d.ॱʿ));
                } else {
                    i = -16777216;
                }
                this.ᐝ.setTextColor(i);
                this.ʼ.setTextColor(i);
                i = c.ˊˊ;
                int i2 = o.ewm.e.ˋˊ;
                if (!evf.ˊ(ʽ())) {
                    ckd o_dke = new dke(this.ʼ.getContext(), this.ʼॱ.getResources().getColor(i), -16777216, i2, false, erq.ˊ(-1, 0.6f));
                    if (ʽ() != null) {
                        ʽ().setButtonStyle(o_dke);
                        ʽ().setIsImmersion(true);
                        ʽ().ॱ();
                    }
                }
            } catch (IllegalStateException e) {
                Logger.e("SubstanceListCardDlItem", e.toString());
            }
        }
    }
}
